package com.itsu.manage.controller;

import com.itsu.manage.service.AppDashboardService;
import com.itsu.pojo.vo.SummaryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("dashboard")
public class DashboardController {

    @Autowired
    AppDashboardService appDashboardService;

    //概要统计 首页第一部分
    @GetMapping("summary")
    public ResponseEntity summary() {
        SummaryVo data = appDashboardService.getSummary();
        return ResponseEntity.ok(data);
    }

    //线性图 首页第二部分
    @GetMapping("users")
    public ResponseEntity users(@RequestParam("sd") Long sd,
                                @RequestParam("ed") Long ed,
                                @RequestParam("type") String type) {
         Map<String, Object> data = appDashboardService.getUsers(sd, ed, type);
        return ResponseEntity.ok(data);
    }

    //分布信息 首页第三部分
    @GetMapping("distribution")
    public ResponseEntity distribution(@RequestParam("sd") Long sd,
                                @RequestParam("ed") Long ed) {
        Map<String, Object> data = appDashboardService.getDistribution(sd, ed);
        return ResponseEntity.ok(data);
    }
}
